﻿using AutoMapper;
using MediatR;
using S.Breeding.Domain;
using S.Breeding.Infrastructure;
using S.Breeding.Read.Api.Application.Command.OustManageCommand;

namespace S.Breeding.Read.Api.Application.CommandHandlers.OustManageCommandHandlers
{
    public class OustManageFindCommandHandlers : IRequestHandler<OustManageFindCommand, List<OustManage>>
    {
        private readonly IRepository<OustManage> repository;
        private readonly IMapper mapper;
        public OustManageFindCommandHandlers(IRepository<OustManage> repository, IMapper mapper)
        {
            this.repository = repository;
            this.mapper = mapper;
        }

        public async Task<List<OustManage>> Handle(OustManageFindCommand request, CancellationToken cancellationToken)
        {
            var list =  repository.All().Result.Where(x => x.SheepTypeId == 1);
            return list.ToList();
        }
    }
}